<template>
    <el-dialog :title="title" :visible.sync="gzOpen" width="60%" :before-close="closeDelDialog">
        <el-tabs v-model="activeName" @tab-click="handleClick">
            <el-tab-pane label="第一步：设置组盘规则" name="first">
                <el-row :gutter="10" class="mb8" ref="refbut">
                    <el-col :span="1.5">
                        <el-button type="primary" plain icon="el-icon-plus" @click="handleAdd">添加</el-button>
                    </el-col>
                </el-row>
                <el-table ref="table" v-loading="loading" :data="plateRuleList" height="600"
                    @selection-change="handleSelectionChange" border stripe>
                    <el-table-column type="selection" width="50" align="center" fixed="left" />
                    <el-table-column label="档案门类" prop="categoryName" align="center" :show-overflow-tooltip="true" />
                    <el-table-column label="全宗" prop="fonds" align="center" :show-overflow-tooltip="true" />
                    <el-table-column label="密级" prop="mjs" align="center"></el-table-column>
                    <el-table-column label="年度" prop="startYear" align="center"></el-table-column>
                    <el-table-column label="操作" align="center">
                        <template slot-scope="scope">
                            <el-button plain type="success" size="mini" @click="handleGzUpdate(scope.row)">修改</el-button>
                            <el-button plain type="danger" size="mini" @click="handleGzDelete(scope.row)">删除</el-button>
                        </template>
                    </el-table-column>
                </el-table>
                <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum"
                    :limit.sync="queryParams.pageSize" @pagination="yqSetPlateRuleListPost" />
            </el-tab-pane>
            <el-tab-pane label="第二步：组盘方案" name="second">
                <el-card class="box-card" style="margin-bottom:10px" v-for="(item,index) in secondList" :key="index">
                    <el-descriptions title="">
                        <el-descriptions-item label="盘号">{{item.arr.index}}</el-descriptions-item>
                        <el-descriptions-item label="总量">{{item.arr.numMb}}M</el-descriptions-item>
                        <el-descriptions-item label="总数">{{item.arr.num}}条</el-descriptions-item>
                    </el-descriptions>
                    <el-table ref="table" :data="item.data" border stripe>
                        <!-- <el-table-column type="selection" width="50" align="center" fixed="left" /> -->
                        <el-table-column label="档案门类" prop="categoryName" align="center" :show-overflow-tooltip="true" />
                        <el-table-column label="档号" prop="dh" align="center" :show-overflow-tooltip="true" />
                        <el-table-column label="数据包位置" prop="path" align="center"></el-table-column>
                        <el-table-column label="数据包大小" prop="size" align="center"></el-table-column>
                    </el-table>
                </el-card>
            </el-tab-pane>
            <el-tab-pane label="第三步：完成组盘" name="third">
                <el-card class="box-card" style="margin-bottom:10px" v-for="(item,index) in secondList" :key="index">
                    <el-row>
                      <el-col :span="19">
                        <el-descriptions title="">
                        <el-descriptions-item label="盘号">{{item.arr.index}}</el-descriptions-item>
                        <el-descriptions-item label="总量">{{item.arr.numMb}}M</el-descriptions-item>
                        <el-descriptions-item label="总数">{{item.arr.num}}条</el-descriptions-item>
                    </el-descriptions>
                      </el-col>
                      <el-col :span="5">
                        <el-button type="primary" @click="handleExport(item.data)">下载</el-button>
                        <el-button type="warning" @click="handleTree(item.data)">下载到指定载体</el-button>
                      </el-col>
                    </el-row>

                    <el-table ref="table" :data="item.data" border stripe style="margin-top:10px;">
                        <!-- <el-table-column type="selection" width="50" align="center" fixed="left" /> -->
                        <el-table-column label="档案门类" prop="categoryName" align="center" :show-overflow-tooltip="true" />
                        <el-table-column label="档号" prop="dh" align="center" :show-overflow-tooltip="true" />
                        <el-table-column label="数据包位置" prop="path" align="center"></el-table-column>
                        <el-table-column label="数据包大小" prop="size" align="center"></el-table-column>
                    </el-table>
                </el-card>
            </el-tab-pane>
        </el-tabs>

        <!--start  新增组盘 -->
        <el-dialog :title="addForm.id==undefined?'新增':'修改'"  :visible.sync="addOpen" width="60%" append-to-body :before-close="cancelForm">
            <div>
                <el-form ref="addForm" :model="addForm" :rules="rules" label-width="80px">
                    <el-form-item label="档案门类" prop="categoryName">
                        <treeselect v-model="addForm.categoryId" :options="options" label placeholder="请选择门类"
                            @select="onChangeTap($event)"   @input="treeSelectInput($event)" :disable-branch-nodes="true"  />
                    </el-form-item>
                    <el-form-item label="年度" prop="startYear">
                        <el-date-picker v-model="addForm.startYear" type="year" value-format="yyyy" placeholder="选择开始年度"
                            @change="handleStartYearChange">
                        </el-date-picker>
                        <span style="margin:0 10px">-</span>
                        <el-date-picker v-model="addForm.endTime" type="year" value-format="yyyy" placeholder="选择结束年度"
                            :min-date="addForm.startYear" @change="handleEndYearChange">
                        </el-date-picker>
                    </el-form-item>
                    <el-form-item label="全宗" prop="fondsCode">
                        <el-radio-group v-model="fondsSelection" @change="fondsChange">
                            <el-radio v-for="option in fondsOption" :key="option.value" :label="option">{{ option.label
                            }}</el-radio>
                        </el-radio-group>
                    </el-form-item>
                    <el-form-item label="保管期限" prop="bgqx">
                        <div style="display: flex; flex-wrap: wrap-reverse;">
                            <el-checkbox :indeterminate="bgqxIndeterminate" style="margin-right: 20px;"
                                v-model="bgqxCheckAll" @change="bgqxAllChange">全选</el-checkbox>
                            <el-checkbox-group v-model="bgqxSelection" style="width: 90%;" @change="bgqxChange">
                                <el-checkbox v-for="option in dict.type.BGQX" :key="option.value" :label="option">{{
                                    option.label }}</el-checkbox>
                            </el-checkbox-group>
                        </div>
                    </el-form-item>
                    <el-form-item label="密级" prop="mj">
                        <div style="display: flex; flex-wrap: wrap-reverse;">
                            <el-checkbox :indeterminate="mjIndeterminate" style="margin-right: 20px;" v-model="mjCheckAll"
                                @change="mjAllChange">全选</el-checkbox>
                            <el-checkbox-group v-model="mjSelection" style="width: 90%;" @change="mjChange">
                                <el-checkbox v-for="option in dict.type.MJ" :key="option.value" :label="option">{{
                                    option.label }}</el-checkbox>
                            </el-checkbox-group>
                        </div>
                    </el-form-item>
                </el-form>
            </div>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="submitForm">确 定</el-button>
                <el-button @click="cancelForm">取 消</el-button>
            </div>
        </el-dialog>
        <!--end  新增组盘 -->


        <!--start 获取载体树 -->
        <el-dialog title="载体管理" :visible.sync="ztOpen" width="30%" append-to-body :before-close="cancelForm">
            <el-tree :data="ztData"  default-expand-all :props="defaultProps" @node-click="handleNodeClick"></el-tree>
            <div slot="footer" class="dialog-footer">
                <el-button type="primary" @click="ztSubmitForm">确 定</el-button>
                <el-button @click="cancelForm">取 消</el-button>
            </div>
        </el-dialog>
        <!-- end 获取载体树-->
    </el-dialog>
</template>
<script>
import { yqSetPlateRuleAdd, yqSetPlateRuleList, yqSetPlateRuleID, yqSetPlateRuleDelete, setPlantDetail,yqSetPlateRuleTree,listPackage,yqSetPlateRuleeditItem } from "@/api/cqbc/resourceManagement/yqSetPlate.js"
import Treeselect from "@riophae/vue-treeselect";
import "@riophae/vue-treeselect/dist/vue-treeselect.css";
import { listGROUPTree } from "@/api/archive/archivesCategory.js";
import { getFondsByTenantCode } from "@/api/archive/archiveTreeDefinition";
export default {
    archive_Dicts: ['BGQX', 'MJ'],
    props: ["gzOpen", "plateId"],
    components: {
        Treeselect
    },
    watch:{
        plateId: {
            handler(val) {
                console.log(val,"sdkfjsdkljf")
                this.queryParams.plateId=val.id
            },
            immediate: true
        },
    },
    data() {
        return {
            categoryInfo: {},
            loading: true,
            // 选中数组
            ids: [],
            // 非单个禁用
            single: true,
            // 非多个禁用
            multiple: true,
            items: [],
            queryParams: {
                pageNum: 1,
                pageSize: 10,
                plateId:undefined
            },
            title: "组盘规则",
            activeName: 'first',
            addOpen: false,
            ztOpen:false,
            defaultProps: {
          children: 'children',
          label: 'label'
        },
        ztData:[],
            fondsOption: [],
            addForm: {
                fondsCode: undefined,
                categoryName: undefined,
                categoryId: undefined,
                bgqx: undefined,
                mj: undefined,
                startYear: undefined,
                endTime: undefined,
            },
            options: [],


            //全宗号
            fondsSelection: {},
            // 保管期限
            bgqxIndeterminate: false,
            bgqxCheckAll: false,
            bgqxSelection: [],
            // 密级
            mjIndeterminate: false,
            mjCheckAll: false,
            mjSelection: [],
            rules: {
                categoryName: [
                    { required: true, message: "请选择档案门类" },
                ],
                startYear: [
                    { required: true, message: "请选择开始年度", trigger: 'blur' },
                ],
                endTime: [
                    { required: true, message: "请选择结束年度", trigger: 'blur' },
                ],
                fondsCode: [
                    { required: true, message: "请选择全宗", trigger: 'blur' },
                ],
                bgqx: [
                    { required: true, message: "请选择保管期限", trigger: 'blur' },
                ],
                mj: [
                    { required: true, message: "请选择密级", trigger: 'blur' },
                ],
            },
            plateRuleList: [],//组盘规则列表
            total: 0,
            secondList:[], //第二部组盘方案列表
            ztItem:[],//第三部载体数据
        }
    },
    created() {
        this.yqSetPlateRuleListPost();//组盘规则列表查询
        this.categorylistPOST(); //档案门类树列表
        this.generalArchive();   // 获取全宗数据列表
    },
    methods: {
        //清楚值得时候触发
        treeSelectInput(value, instanceId) {
            console.log(value, 'input事件')
            if(value==undefined){
                this.categoryInfo = {};
                this.addForm.categoryName = undefined;
                this.addForm.categoryId=undefined;
            }
           
            },
        //组盘规则列表查询
        yqSetPlateRuleListPost() {
            yqSetPlateRuleList(this.queryParams).then(res => {
                this.loading = false;
                this.total = res.total;
                this.plateRuleList = res.rows;
            })
        },
        table_index(index) {
            return (this.queryParams.pageNum - 1) * this.queryParams.pageSize + index + 1;
        },
        // 多选框选中数据
        handleSelectionChange(selection) {
            this.ids = selection.map(item => item.id)
            this.items = selection;
            this.single = selection.length !== 1
            this.multiple = !selection.length
        },
        //选择门类
        onChangeTap(val) {
            console.log(val,'sdkflj')
            this.categoryInfo = val
            this.addForm.categoryName = val.label

        },
        submitForm() {
            console.log(this.addForm, "sdklfjklsdfjsdklj")

            this.$refs["addForm"].validate(valid => {
                if (valid) {
                    if (this.categoryInfo.label == null) {
                        this.$message({ message: ' 请选择档案门类哦~', type: 'warning' })
                        return false
                    }

                    if(this.addForm.id!=undefined){
                        yqSetPlateRuleeditItem(this.addForm).then(res=>{
                            if (res.code == "200") {
                            this.$refs.addForm.resetFields();
                            this.reset();
                            this.$modal.msgSuccess("修改成功");
                            this.yqSetPlateRuleListPost();
                            this.addOpen = false
                        }
                        })
                    }else{
                        this.addForm["plateId"] = this.plateId.id;
                        yqSetPlateRuleAdd(this.addForm).then(res => {
                        if (res.code == "200") {
                            this.$refs.addForm.resetFields();
                            this.reset();
                            this.$modal.msgSuccess("添加成功");
                            this.yqSetPlateRuleListPost();
                            this.addOpen = false
                        }
                    })
                    }


                }
            })


        },
        cancelForm() {
            console.log(this.$refs.addForm,"sdklfjsdklfjjkl")
            if(this.$refs.addForm!=undefined){
                this.$refs.addForm.resetFields();
            this.reset();
            }

            this.addOpen = false;
            this.ztOpen=false;
        },

        // 表单重置
        reset() {
            this.addForm = {
                fondsCode: undefined,
                categoryName: undefined,
                bgqx: undefined,
                mj: undefined,
                startYear: undefined,
                endTime: undefined,
                categoryId: undefined
            }
            //全宗号
            this.fondsSelection = {}
            // 保管期限
            this.bgqxIndeterminate = false
            this.bgqxCheckAll = false
            this.bgqxSelection = []
            // 密级
            this.mjIndeterminate = false
            this.mjCheckAll = false
            this.mjSelection = []
        },
        //档案门类树列表
        categorylistPOST() {
            listGROUPTree().then(response => {
                this.options = response.data;
            });

        },
        // 获取全宗数据列表
        generalArchive() {
            getFondsByTenantCode().then(response => {
                this.fondsOption = response.data.map(option => {
                    return {
                        value: option.fondsCode,
                        label: option.fondsName
                    }
                })
            })
        },

        //全宗勾选
        fondsChange(val) {
            this.fondsSelection = val;
            this.addForm.fondsCode = val.value;
        },
        // 保管期限勾选
        bgqxAllChange(val) {
            this.bgqxSelection = val ? this.dict.type.BGQX : [];
            this.bgqxIndeterminate = false;
            this.addForm.bgqx = this.dict.type.BGQX.map(item => item.value).toString()
        },
        bgqxChange(value) {

            let checkedCount = value.length;
            this.bgqxCheckAll = checkedCount === this.dict.type.BGQX.length;
            this.bgqxIndeterminate = checkedCount > 0 && checkedCount < this.dict.type.BGQX.length;
            this.addForm.bgqx = value.map(item => item.value).toString()
        },
        // 密级勾选
        mjAllChange(val) {
            this.mjSelection = val ? this.dict.type.MJ : [];
            this.mjIndeterminate = false;
            this.addForm.mj = this.dict.type.MJ.map(item => item.value).toString()
        },
        mjChange(value) {
            let checkedCount = value.length;
            this.mjCheckAll = checkedCount === this.dict.type.MJ.length;
            this.mjIndeterminate = checkedCount > 0 && checkedCount < this.dict.type.MJ.length;
            this.addForm.mj = value.map(item => item.value).toString()
        },
        handleStartYearChange() {
            if (this.addForm.endTime < this.addForm.startYear) {
                this.addForm.startYear = this.endTime;
            }
        },
        handleEndYearChange() {
            if (this.addForm.endTime < this.addForm.startYear) {
                this.addForm.endTime = this.addForm.startYear;
            }
            if (!this.addForm.startYear) {
                this.addForm.startYear = this.addForm.endTime;
            }
        },

        handleClick(tab, event) {
            console.log(tab, event)
            if (!this.multiple) {
                if (tab.name == "second") {
                    this.setPlantDetailPost(); //第二步组盘方案
                } else if (tab.name == "third") {
                    this.setPlantDetailPost(); //第三步完成组盘
                } else {
                    this.yqSetPlateRuleListPost();
                }
            } else {
                this.$modal.msgWarning("请选择条件数据");
            }
        },
        //修改组盘规则
        handleGzUpdate(row) {
            var that = this;
            console.log(row.id, "lskdjfkl")
            this.addOpen = true;
            //组盘规则详情
            yqSetPlateRuleID(row.id).then(response => {
                console.log(response.data,"sdklfjsdklf")
                this.addForm = response.data;
                this.categoryInfo.label=response.data.categoryName;
                this.categoryInfo.id=response.data.categoryId;
                //全宗
                var fondsid = this.fondsOption.filter(item => this.addForm.fondsCode == item.value)
                this.fondsSelection = fondsid[0];
                // 保管期限回显
                var bgqxArr = response.data.bgqx.split(',')
                var arr1 = []
                for (let i = 0; i < bgqxArr.length; i++) {
                    const data = this.dict.type.BGQX.filter(item => item.value == bgqxArr[i])
                    arr1 = arr1.concat(data)
                }
                this.bgqxSelection = arr1
                let checkedCount1 = bgqxArr.length;
                this.bgqxCheckAll = checkedCount1 === this.dict.type.BGQX.length;
                this.bgqxIndeterminate = checkedCount1 > 0 && checkedCount1 < this.dict.type.BGQX.length;
                // 密级回显
                var mjArr = response.data.mj.split(',')
                var arr2 = []
                for (let i = 0; i < mjArr.length; i++) {
                    const data = this.dict.type.MJ.filter(item => item.value == mjArr[i])
                    arr2 = arr2.concat(data)
                }
                this.mjSelection = arr2
                let checkedCount2 = mjArr.length;
                this.mjCheckAll = checkedCount2 === this.dict.type.MJ.length;
                this.mjIndeterminate = checkedCount2 > 0 && checkedCount2 < this.dict.type.MJ.length;
            })
        },
        //删除组盘
        handleGzDelete(row) {
            this.$modal.confirm('是否确认删除数据？').then(function () {
                return yqSetPlateRuleDelete(row.id)

            }).then(response => {
                this.yqSetPlateRuleListPost();
                this.$modal.msgSuccess(response.msg);
            }).catch(() => { });
        },
        //添加组盘规则
        handleAdd() {
            var that = this;
            this.addOpen = true
        },

        //第二步组盘方案
        setPlantDetailPost() {
            console.log(this.plateId,"sdklfjsdklfjsdklj")
            setPlantDetail({
                size: this.plateId.size * 1024 * 1024,
                count: this.plateId.quantity,
                items: this.items
            }).then(res => {
                console.log(res.data)
                // var arrData = [
                //     [
                //         {
                //             batch: "",
                //             biaoshi: null,
                //             category: "237769902855950336",
                //             categoryId: null,
                //             categoryName: "测试开放鉴定件",
                //             chukuState: null,
                //             createBy: null,
                //             createTime: null,
                //             date: "dolor occaecat",
                //             deleteState: null,
                //             detectionTime: "2023-07-20",
                //             dh: "J232-WS-2021-D10-0015",
                //             exam: "",
                //             filePath: null,
                //             fonds: "001",
                //             format: "zip",
                //             id: "1681584190664613889",
                //             ischuku: null,
                //             isdel: "1",
                //             md5Str: "cb9a38a71fde4650b5051c2492a89ae3",
                //             menuId: null,
                //             migrated: "0",
                //             name: "1",
                //             outboundTime: null,
                //             path: "D:/HD_MNT/LONG_TIME_SAVE/\\WS",
                //             receivingTime: "",
                //             remark: "",
                //             resolved: "1",
                //             saveTime: "mollit voluptate labore",
                //             sixing: "200",
                //             sixingDetail: "326231344088748032",
                //             size: "8888824",
                //             state: "",
                //             storageWay: "do",
                //             template: "",
                //             tenantCode: "A001",
                //             title: "验证文件",
                //             updateBy: null,
                //             updateTime: null,
                //             zlfs: "0"
                //         }, {
                //             batch: "",
                //             biaoshi: null,
                //             category: "237769902855950336",
                //             categoryId: null,
                //             categoryName: "测试开放鉴定件",
                //             chukuState: null,
                //             createBy: null,
                //             createTime: null,
                //             date: "dolor occaecat",
                //             deleteState: null,
                //             detectionTime: "2023-07-20",
                //             dh: "J232-WS-2021-D10-0015",
                //             exam: "",
                //             filePath: null,
                //             fonds: "001",
                //             format: "zip",
                //             id: "1681584190664613889",
                //             ischuku: null,
                //             isdel: "1",
                //             md5Str: "cb9a38a71fde4650b5051c2492a89ae3",
                //             menuId: null,
                //             migrated: "0",
                //             name: "1",
                //             outboundTime: null,
                //             path: "D:/HD_MNT/LONG_TIME_SAVE/\\WS",
                //             receivingTime: "",
                //             remark: "",
                //             resolved: "1",
                //             saveTime: "mollit voluptate labore",
                //             sixing: "200",
                //             sixingDetail: "326231344088748032",
                //             size: "1024",
                //             state: "",
                //             storageWay: "do",
                //             template: "",
                //             tenantCode: "A001",
                //             title: "验证文件",
                //             updateBy: null,
                //             updateTime: null,
                //             zlfs: "0"
                //         }
                //     ], [


                //         {
                //             batch: "",
                //             biaoshi: null,
                //             category: "237769902855950336",
                //             categoryId: null,
                //             categoryName: "测试开放鉴定件",
                //             chukuState: null,
                //             createBy: null,
                //             createTime: null,
                //             date: "dolor occaecat",
                //             deleteState: null,
                //             detectionTime: "2023-07-20",
                //             dh: "J232-WS-2021-D10-0015",
                //             exam: "",
                //             filePath: null,
                //             fonds: "001",
                //             format: "zip",
                //             id: "1681584190664613889",
                //             ischuku: null,
                //             isdel: "1",
                //             md5Str: "cb9a38a71fde4650b5051c2492a89ae3",
                //             menuId: null,
                //             migrated: "0",
                //             name: "1",
                //             outboundTime: null,
                //             path: "D:/HD_MNT/LONG_TIME_SAVE/\\WS",
                //             receivingTime: "",
                //             remark: "",
                //             resolved: "1",
                //             saveTime: "mollit voluptate labore",
                //             sixing: "200",
                //             sixingDetail: "326231344088748032",
                //             size: "4",
                //             state: "",
                //             storageWay: "do",
                //             template: "",
                //             tenantCode: "A001",
                //             title: "验证文件",
                //             updateBy: null,
                //             updateTime: null,
                //             zlfs: "0"
                //         }, {
                //             batch: "",
                //             biaoshi: null,
                //             category: "237769902855950336",
                //             categoryId: null,
                //             categoryName: "测试开放鉴定件",
                //             chukuState: null,
                //             createBy: null,
                //             createTime: null,
                //             date: "dolor occaecat",
                //             deleteState: null,
                //             detectionTime: "2023-07-20",
                //             dh: "J232-WS-2021-D10-0015",
                //             exam: "",
                //             filePath: null,
                //             fonds: "001",
                //             format: "zip",
                //             id: "1681584190664613889",
                //             ischuku: null,
                //             isdel: "1",
                //             md5Str: "cb9a38a71fde4650b5051c2492a89ae3",
                //             menuId: null,
                //             migrated: "0",
                //             name: "1",
                //             outboundTime: null,
                //             path: "D:/HD_MNT/LONG_TIME_SAVE/\\WS",
                //             receivingTime: "",
                //             remark: "",
                //             resolved: "1",
                //             saveTime: "mollit voluptate labore",
                //             sixing: "200",
                //             sixingDetail: "326231344088748032",
                //             size: "1024",
                //             state: "",
                //             storageWay: "do",
                //             template: "",
                //             tenantCode: "A001",
                //             title: "验证文件",
                //             updateBy: null,
                //             updateTime: null,
                //             zlfs: "0"
                //         }, {
                //             batch: "",
                //             biaoshi: null,
                //             category: "237769902855950336",
                //             categoryId: null,
                //             categoryName: "测试开放鉴定件",
                //             chukuState: null,
                //             createBy: null,
                //             createTime: null,
                //             date: "dolor occaecat",
                //             deleteState: null,
                //             detectionTime: "2023-07-20",
                //             dh: "J232-WS-2021-D10-0015",
                //             exam: "",
                //             filePath: null,
                //             fonds: "001",
                //             format: "zip",
                //             id: "1681584190664613889",
                //             ischuku: null,
                //             isdel: "1",
                //             md5Str: "cb9a38a71fde4650b5051c2492a89ae3",
                //             menuId: null,
                //             migrated: "0",
                //             name: "1",
                //             outboundTime: null,
                //             path: "D:/HD_MNT/LONG_TIME_SAVE/\\WS",
                //             receivingTime: "",
                //             remark: "",
                //             resolved: "1",
                //             saveTime: "mollit voluptate labore",
                //             sixing: "200",
                //             sixingDetail: "326231344088748032",
                //             size: "338085",
                //             state: "",
                //             storageWay: "do",
                //             template: "",
                //             tenantCode: "A001",
                //             title: "验证文件",
                //             updateBy: null,
                //             updateTime: null,
                //             zlfs: "0"
                //         }, {
                //             batch: "",
                //             biaoshi: null,
                //             category: "237769902855950336",
                //             categoryId: null,
                //             categoryName: "测试开放鉴定件",
                //             chukuState: null,
                //             createBy: null,
                //             createTime: null,
                //             date: "dolor occaecat",
                //             deleteState: null,
                //             detectionTime: "2023-07-20",
                //             dh: "J232-WS-2021-D10-0015",
                //             exam: "",
                //             filePath: null,
                //             fonds: "001",
                //             format: "zip",
                //             id: "1681584190664613889",
                //             ischuku: null,
                //             isdel: "1",
                //             md5Str: "cb9a38a71fde4650b5051c2492a89ae3",
                //             menuId: null,
                //             migrated: "0",
                //             name: "1",
                //             outboundTime: null,
                //             path: "D:/HD_MNT/LONG_TIME_SAVE/\\WS",
                //             receivingTime: "",
                //             remark: "",
                //             resolved: "1",
                //             saveTime: "mollit voluptate labore",
                //             sixing: "200",
                //             sixingDetail: "326231344088748032",
                //             size: "1024",
                //             state: "",
                //             storageWay: "do",
                //             template: "",
                //             tenantCode: "A001",
                //             title: "验证文件",
                //             updateBy: null,
                //             updateTime: null,
                //             zlfs: "0"
                //         }
                //     ]
                // ]
                var arrData=res.data;
                // console.log(arrData,"9999999999999999999999999999")
                for(var i in arrData){
                    var index,numMb=0,num=0
                    num = arrData[i].length
                    index=Number(i)+1
                    var data=[];
                    arrData[i].forEach(item=>{

                        item.size=item.size/1024/1024

                        numMb+=item.size

                        item.size=item.size.toFixed(2)+"M"
                        data.push(item)
                    })

                    numMb = numMb.toFixed(2)

                    arrData[i]={
                        data:data,
                        arr:{
                            index:index,
                            numMb:numMb,
                            num:num
                        }
                    }

                }
                this.secondList=arrData;
            })
        },

        //下载
        handleExport(item){
            console.log(JSON.stringify(item),"sdklfjsdkljfklsdjfkl")
            this.downloadHeader('/cqbc/yqSetPlateRule/listPackage', {
                ...{data:JSON.stringify(item)}
            }, `basicdata_${new Date().getTime()}.zip`)
        },
        //下载到指定的载体
        handleTree(item){
            this.ztOpen=true
            this.ztItem=item;
            this.yqSetPlateRuleTreePost();
        },
       //获取载体树
        yqSetPlateRuleTreePost(){
            yqSetPlateRuleTree().then(res=>{
                this.ztData=res.data;
            })
        },
        //选择下拉
        handleNodeClick(data){
            this.ztinfo=data;

        },
        ztSubmitForm(){

            if(this.ztinfo==undefined){
                this.$message({ message: '请选择数据哦', type: 'warning' })
                return
            }
            this.$modal.loading("加载中...")
            listPackage({
              id:this.ztinfo.id,
              data:this.ztItem
            }).then(res=>{
                console.log(res,"sdklfjskldjfklsdjfklsdjiazai")
                this.ztOpen=false;
                this.$modal.closeLoading()
                this.$modal.msgSuccess("转移指定载体成功!")
            }).catch(error=>{
                this.$modal.closeLoading()
            })
        },
        closeDelDialog() {
            this.$emit("closeZPGZDialog")
        }

    }
}

</script>
<style lang="scss" scoped>
::v-deep .el-dialog {
    display: flex;
    flex-direction: column;
    margin: 0 !important;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    max-height: calc(100% - 30px);
    max-width: calc(100% - 30px);
}

::v-deep .el-dialog .el-dialog__body {
    flex: 1;
    overflow: auto;
}</style>

